package logic

import (
	"context"
	"fmt"
	"merchantmanage/models/mysql"

	"merchantmanage/userrpc/internal/svc"
	"merchantmanage/userrpc/userrpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type GoodsDelLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewGoodsDelLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GoodsDelLogic {
	return &GoodsDelLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *GoodsDelLogic) GoodsDel(in *userrpc.GoodsDelRequest) (*userrpc.GoodsDelResponse, error) {
	// todo: add your logic here and delete this line

	err := mysql.DB.Debug().Delete(&mysql.Goods{}, in.GoodId).Error
	if err != nil {
		return nil, fmt.Errorf("删除失败")
	}

	return &userrpc.GoodsDelResponse{}, nil
}
